<!-- 外部建设 -->
<template>
  <div class="zs-table-page-container">
    <SearchHeader :tabType="tabType" @onChange="changeTab" @onSearch="search">
    </SearchHeader>
    <TwoControlTableBudget v-show="tabType == 1 && tableListTwoControl && benchmarkType == 0" :tableList="tableListTwoControl" :yearmonth="yearmonth" :isFresh="isFresh">
    </TwoControlTableBudget>
    <TwoControlTableStandard v-show="tabType == 1 && tableListTwoControl && benchmarkType == 1" :tableList="tableListTwoControl" :yearmonth="yearmonth" :isFresh="isFresh">
    </TwoControlTableStandard>
    <FinanceTable v-show="tabType == 2 && tableList" :tableList="tableList" :yearmonth="yearmonth" :isFresh="isFresh">
    </FinanceTable>
  </div>
</template>
<script setup>
import SearchHeader from '@/views/SpecialReport/lightAssetExtConBudget/components/searchHeader'
import TwoControlTableBudget from '@/views/SpecialReport/lightAssetExtConBudget/components/twoControlTableBudget'
import TwoControlTableStandard from '@/views/SpecialReport/lightAssetExtConBudget/components/twoControlTableStandard'
import FinanceTable from '@/views/SpecialReport/lightAssetExtConBudget/components/financeTable'
import { extConBudgetListApi, benchmarkingTwoCalAndOneConListApi } from '@/api/SpecialReport/twoControl';
import { ref } from 'vue'
// tabType 右侧tab： 1 两算一控 2 财务口径
const tabType = ref(1)
const changeTab = (data) => {
  tabType.value = data.data
}

const isFresh = ref('');
const yearmonth = ref('');
const benchmarkType = ref('')
const tableListTwoControl = ref([])
const tableList = ref([])

const search = async (data) => {
  yearmonth.value = data.yearmonth
  benchmarkType.value = data.benchmarkType
  await benchmarkingTwoCalAndOneConListApi(data).then(res => {
    if (res.data.code == 200) {
      tableListTwoControl.value = res.data.data
    }
  })
  await extConBudgetListApi({projectCode: data.projectCode, yearmonth: data.yearmonth}).then(res => {
    if (res.data.code == 200) {
      tableList.value = res.data.data
    }
  })
  isFresh.value = new Date().getTime();

}
</script>

<style scoped lang="scss"></style>
